#pragma once
#include "Macro.h"
#include <sstream>
class LogStream
{
	delete_class_copy_operator(LogStream);
public:
	LogStream(size_t level, WriteLogFunc func) :_level(level)
	{
		_func = func;
	}

	~LogStream()
	{
		std::string log = std::move(_sstr.str());
		_func(_level, log);
	}


	template<class T>
	LogStream& operator<< (const T& log)
	{
		if (typeid(bool) == typeid(T)) {
			_sstr << std::boolalpha << log;
		}
		else {
			_sstr << log;
		}
		return *this;
	}

	LogStream& operator<< (LogStream&(LogStream&))
	{
		_sstr << std::endl;
		return *this;
	}
private:
	WriteLogFunc _func;
	std::stringstream _sstr;
	size_t _level;
};

inline LogStream& endl(LogStream& logstream)
{
	return logstream;
}